package com.study.stack;

import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat;
import java.util.*;

class user{
    int a;

    public user(int a) {
        this.a = a;
    }


    protected void finalize() throws Throwable {
        System.out.println(this.a + "====我被回收了");
        super.finalize();
    }
}

class Stu{
    @Override
    protected void finalize() throws Throwable {
        System.out.println("我被回收了");
        super.finalize();
    }
}

public class Test {


    public static void main(String[] args) {
// weakReference封装ThreadLocal 原因演示
//        user user1 = new user(1);
//        user user2 = new user(2);
//        Map<Object,Object> map  = new HashMap();
//        WeakReference<user> userWeakReference = new WeakReference<>(user1);
//        map.put(userWeakReference,user2);
//
//       // user1 =null;
//        System.out.println(map.get(user1));
//        Set<Object> objects = map.keySet();
//        Stu stu = new Stu();
//        stu =null;
//        System.gc();






        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd");
        Scanner scanner = new Scanner(System.in);
        try {
            Date date = simpleDateFormat.parse("2021.12.05");


            Boolean loop= true;
            while (loop){
                System.out.println("输入查询日期");
                String key = scanner.next();
                Date newDate =  simpleDateFormat.parse(key);
                long day = (newDate.getTime()-date.getTime())/(1000*60*60*24);
                int res = Integer.parseInt(String.valueOf(day%4));
                switch (res){
                    case 0:
                        System.out.println("白班");
                        break;
                    case 1:
                        System.out.println("夜班");
                        break;
                    case 2:
                        System.out.println("下夜班");
                        break;
                    case 3:
                        System.out.println("休息");
                        break;
                    case 5:
                        loop =false;
                        System.out.println("程序退出");
                    default:
                        System.out.println("日期已经过期");
                }
            }

        }catch (Exception e){
            e.printStackTrace();

        }







    }
}